import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class LocalStorageService {

  private localStorage: any;
  constructor() {
    if (!window.localStorage) {
      console.error('你的电脑不支持localStorage！');
    } else {
      this.localStorage = window.localStorage;
    }
  }

  public get(name): string {
    return this.localStorage.getItem(name) || '';
  }


  public set(name, val): void {
    this.localStorage.setItem(name, val);
  }
}
